/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package daos;

import beans.Bean;
import beans.TurnoEntreFechasBeans;
import beans.TurnosDisponiblesBean;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author C
 */
public class MSSQLTurnoDisponibleDao extends MSSQLDao implements Dao{

    public MSSQLTurnoDisponibleDao() throws Exception {
        super();
    }  
    
     public MSSQLTurnoDisponibleDao(String db) throws Exception {         
        super(db);      
    } 

    @Override
    public Bean make(ResultSet result) throws Exception {
        TurnosDisponiblesBean turno = new TurnosDisponiblesBean(); 
        turno.setIdTurno(result.getInt("id_turno"));
        turno.setApellidoProfesional(result.getString("apellido_profesional"));
        turno.setNombreProfesional(result.getString("nombre_profesional"));
        turno.setEspecialidad(result.getString("especialidad"));
        turno.setFechaHora(result.getDate("fecha_hora"));
        turno.setTiempo(result.getString("tiempo"));
        turno.setCosto(result.getInt("costo"));
        turno.setConsultorio(result.getString("consultorio"));     
        return turno;
    }

    @Override
    public int insert(Bean bean) throws Exception {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public List<Bean> select(Bean bean) throws Exception {
        ResultSet result;
        List<Bean> turnos=new ArrayList<Bean>();
        if(((TurnoEntreFechasBeans)bean)!=null) {
            this.setStatement("get_turno_entre_fecha(?,?)");
            this.getStatement().setDate(1,new java.sql.Date(((TurnoEntreFechasBeans)bean).getFecha_ini().getTime()));
            this.getStatement().setDate(2,new java.sql.Date(((TurnoEntreFechasBeans)bean).getFecha_fin().getTime()));
        }
        else {
            this.setStatement("get_turnos_disponible");           
        } 
        result=this.getStatement().executeQuery();
        while(result.next()){            
            turnos.add(this.make(result));
        }        
        return turnos;     
    }

    @Override
    public boolean valid(Bean bean) throws Exception {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public Bean get(Bean bean) throws Exception {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public long getSize(Bean bean) throws Exception {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public int update(Bean bean) throws Exception {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public int delete(Bean bean) throws Exception {
        throw new UnsupportedOperationException("Not supported yet.");
    }
    
}